<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */
 

  class b2c_queue{
      function send_mail(&$cursor_id,$params){
          $obj_emailconf = kernel::single('desktop_email_emailconf');
        $aTmp = $obj_emailconf->get_emailConfig();
        $acceptor =  $params['acceptor'];    //收件人邮箱
        $aTmp['shopname'] = app::get('b2c')->getConf('system.shopname');
        $subject = $params['title'];
        $body = $params['body'];
        $email = kernel::single('desktop_email_email');
        $email->ready($aTmp);
        $res = $email->send($acceptor,$subject,$body,$aTmp);
        }
        
        
    function send_msg(&$cursor_id,$params){
        $obj_memmsg = kernel::single('b2c_message_msg');
        $aData = $params['data'];
        $aData['member_id'] = 1;
        $aData['uname'] = app::get('b2c')->_('管理员');
        $aData['to_id'] = $params['member_id'];
        $aData['msg_to'] = $params['name'];
        $aData['subject'] = $aData['title']; 
        $aData['comment'] = $aData['content'];
        $aData['has_sent'] = 'true';
        $obj_memmsg->send($aData);
    }
    
    #发手机短信
    
    function send_sms(&$cursor_id,$params){
        $obj_memmsm = kernel::single('b2c_messenger_sms');
        $objfilter = kernel::service('filter_sms_content');
        $title = $params['data']['title'];
        $message = $params['data']['content'];
        if(is_object($objfilter)){
            if(method_exists($objfilter,'get_filter_content')){
                $data = $objfilter->get_filter_content($title,$message);
                $title = $data['title'];
                $message = $data['content'];
            }
        }
        $to = $params['mobile_number'];
        $config['shopname'] = app::get('site')->getConf('site.name');
        if($obj_memmsm->ready($config)) $obj_memmsm->send($to,$title,$message,$config);
    } 
    ##发到货通知邮件
    function goods_notify(&$cursor_id,$params){
        $obj_emailconf = kernel::single('desktop_email_emailconf');
        $aTmp = $obj_emailconf->get_emailConfig();
        $acceptor = $params['acceptor'];     //收件人邮箱
        $aTmp['shopname'] = app::get('b2c')->getConf('system.shopname');
        $subject = $params['title'];
        #$subject = "biaoti";
        $body = $params['body'];
        #$body = "内容";
        $email = kernel::single('desktop_email_email');
        $email->ready($aTmp);
        $res = $email->send($acceptor,$subject,$body,$aTmp);
        $member_goods = app::get('b2c')->model('member_goods');
        $sdf = $member_goods->dump($params['gnotify_id']);
        $sdf['status'] = "send";
        $sdf['send_time'] = time();
        $member_goods->save($sdf);
    } 
  }
?>
